package com.segi.view.alert;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.segi.view.R;

/**
 * Author: chen
 * Date: [2019/1/8]
 */
public class CustomToastDialog extends Toast {

    public CustomToastDialog(Context context, String str) {
        super(context);
        View v = LayoutInflater.from(context).inflate(R.layout.custom_toast_dialog, null);
        TextView toastTv = (TextView) v.findViewById(R.id.toast_tv);
        toastTv.setText(str);
        toastTv.setGravity(Gravity.CENTER);
        setView(v);
        setDuration(Toast.LENGTH_SHORT);
        setGravity(Gravity.CENTER, 0, 0);
    }

    public CustomToastDialog(Context context, int str) {
        super(context);
        View v = LayoutInflater.from(context).inflate(R.layout.custom_toast_dialog, null);
        TextView toastTv = (TextView) v.findViewById(R.id.toast_tv);
        toastTv.setText(str);
        toastTv.setGravity(Gravity.CENTER);
        setView(v);
        setDuration(Toast.LENGTH_SHORT);
        setGravity(Gravity.CENTER, 0, 0);
    }

    public CustomToastDialog(Context context, CharSequence str) {
        super(context);
        View v = LayoutInflater.from(context).inflate(R.layout.custom_toast_dialog, null);
        TextView toastTv = (TextView) v.findViewById(R.id.toast_tv);
        toastTv.setText(str);
        toastTv.setGravity(Gravity.CENTER);
        setView(v);
        setDuration(Toast.LENGTH_SHORT);
        setGravity(Gravity.CENTER, 0, 0);
    }
}
